<?php

require_once 'db.php';

class works extends DB {

    public function selectW($page=NULL) {
        $this->getConnection();
        $begin=($page-1)*PAGE;
        $query = 'SELECT * FROM works LIMIT ' .$begin.",".PAGE;;
        $works = $this->query($query);
         foreach ($works as $list_works):
            if(strlen($list_works['name']) > 10){
                echo $list_works['id'] ;
                echo $list_works['name']."<br>";
            };
        endforeach;
        return $works;
    }
    
     public function countW() {
        $this->getConnection();
        $query = 'SELECT * FROM works';
        $works = $this->query($query);
        return count($works);
    }
    
     public function selectLenW() {
        $this->getConnection();
        $query = 'SELECT * FROM works LIMIT 0,10';
        $works = $this->query($query);
        foreach ($works as $list_works):
            if(strlen($list_works['name']) > 10){
                echo $list_works['id'] ;
                echo $list_works['name']."<br>";
            };
        endforeach;
        return $works;
    }
}
?>
